

const fs = require("fs");
const path = require("path");
const adminJsonPath = path.join(__dirname, "../json/admin.json");
 

function readAdminJson() {
    try {
        const data = fs.readFileSync(adminJsonPath, "utf8");
        return JSON.parse(data);
    } catch (err) {
        console.error("读取 admin.json 失败:", err);
        return null;
    }
}

function writeAdminJson(data) {
    try {
        fs.writeFileSync(adminJsonPath, JSON.stringify(data, null, 2), "utf8");
    } catch (err) {
        console.error("写入 admin.json 失败:", err);
    }
}

module.exports = {
    readAdminJson,
    writeAdminJson
}